package com.wj.infrastructure.mapper;

import com.wj.domain.vo.BookTypeVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BookTypeMapper {

    @Select(" select bt.id, bt.type_name as typeName, IFNULL(a.count,0) as count from book_type bt " +
            " LEFT JOIN (SELECT b.type, COUNT(b.id) as count from book b " +
            " GROUP BY b.type) a on bt.id=a.type")
    List<BookTypeVO> getTypeList();
}
